#include "IntersecList.h"

int main()
{
    struct ListNode* n1 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* n2 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* n3 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* n4 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* n5 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* n6 = (struct ListNode*)malloc(sizeof(struct ListNode));

    if (n1 == NULL || n2 == NULL || n3 == NULL || n4 == NULL || n5 == NULL || n6 == NULL)
    {
        perror("malloc");
        return -1;
    }

    struct ListNode* head = n1;

    n1->val = 1;
    n2->val = 2;
    n3->val = 3;
    n4->val = 4;
    n5->val = 5;
    n6->val = 6;

    n1->next = n2;
    n2->next = n4;
    n3->next = NULL;
    n4->next = n6;
    n5->next = n4;
    n6->next = n3;

    SListPrint(n1);
    SListPrint(n5);
    struct ListNode* ret = getIntersectionNode(n1, n5);
    printf("%d\n", ret->val);

    return 0;
}